<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title></title>
<#include "/jeecms_sys/head.html"/> 
<script src="${base}/thirdparty/swfupload/swfupload.js" type="text/javascript"></script>
<script src="${base}/thirdparty/swfupload/swfupload.queue.js" type="text/javascript"></script>
<script src="${base}/thirdparty/swfupload/fileprogress.js" type="text/javascript"></script>
<script src="${base}/thirdparty/swfupload/handlers.js" type="text/javascript"></script>
<link href="${base}/thirdparty/swfupload/process.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
$(function() {
	
	//选择框联动,根据品牌获取车系 ,根据车系获取车型
		$("#carBrandId").change(function(){
		if($(this).val()==0){
		$("#carSeriesId").html("");
		$("#carSeriesId").append("<option value="+0+">"+"其它"+"</option>");
		$("#carTypeId").html("");
		$("#carTypeId").append("<option value="+0+">"+"其它"+"</option>");
		document.getElementById("otherCarType").style.display="inline";
		return;
		}
			$.post('getCarSeries.do',
					{bid:$(this).val()},
					function(data,textStatus){
						$("#carSeriesId").html("");
						var json = eval(data);
						$.each(json,function(i,item){
							$("#carSeriesId").append("<option value="+item.sid+">"+item.sname+"</option>");
							document.getElementById("otherCarType").style.display="none";
						});
					});
			
		})
		$("#carSeriesId").change(function(){
		if($(this).val()==0){
		//$("#carBrandId").html("");
		//$("#carBrandId").append("<option value="+0+">"+"其它"+"</option>");
		document.getElementById("carBrandId").value="0";
		$("#carTypeId").html("");
		$("#carTypeId").append("<option value="+0+">"+"其它"+"</option>");
		document.getElementById("otherCarType").style.display="inline";
		return;
		}
			$.post('getCarType.do',
					{sid:$(this).val()},
					function(data,textStatus){
						$("#carTypeId").html("");
						var json = eval(data);
						$.each(json,function(i,item){
							$("#carTypeId").append("<option value="+item.tid+">"+item.tname+"</option>");
							document.getElementById("otherCarType").style.display="none";
						});
					});
			
		})
		
		$("#carTypeId").change(function(){
		if($(this).val()==0){
		//$("#carBrandId").html("");
		//$("#carBrandId").append("<option value="+0+">"+"其它"+"</option>");
		document.getElementById("carBrandId").value="0";
		document.getElementById("carSeriesId").value="0";
		document.getElementById("otherCarType").style.display="inline";
		//$("#carSeriesId").html("");
		//$("#carSeriesId").append("<option value="+0+">"+"其它"+"</option>");
		return;
		}else{
		document.getElementById("otherCarType").style.display="none";
		}
		
			
		})
	
});
var swfu;
window.onload=function() {previewImg(1);
var uploadPicsUrl = "../common/o_swfPicsUpload.do";
	var uploadAttachsUrl = "../common/o_swfAttachsUpload.do";
	//在firefox、chrome下，上传不能保留登录信息，所以必须加上jsessionid。
	var jsessionid = $.cookie("JSESSIONID");
	if(jsessionid) {
		uploadPicsUrl += ";jsessionid="+jsessionid;
		uploadAttachsUrl += ";jsessionid="+jsessionid;
	}

	swfu=new SWFUpload({
		upload_url : uploadPicsUrl,
		flash_url : "${base}/thirdparty/swfupload/swfupload.swf",
		file_size_limit : "20 MB",
		file_types : "*.jpg;*.gif;*.png;*.bmp",
		file_types_description : "<@s.m 'content.picture'/>",
		file_queue_limit : 0,
		custom_settings : {
			progressTarget : "fsUploadProgress",
			cancelButtonId : "btnCancel"
		},
		debug: false,
		
		button_image_url : "${base}/thirdparty/swfupload/button_notext.png",
		button_placeholder_id : "spanButtonPlaceHolder",
		button_text: "<span class='btnText'><@s.m "content.pictures.upload"/></span>",
		button_width: 84,
		button_height: 24,
		button_text_top_padding: 2,
		button_text_left_padding: 20,
		button_text_style: '.btnText{color:#666666;}',
		
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadPicsStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadPicsSuccess,
		upload_complete_handler : uploadComplete,
		queue_complete_handler : queueComplete
	});
};

function uploadPicsStart(file) {
	addPicLine();
}
var picIndex = 3;
var picTpl = $.format($("#picTable").val());
function addPicLine() {
	$('#picBefore').before(picTpl(picIndex++));
}
////

function uploadAttachStart(file) {
	addAttachLine();
}
function uploadAttachSuccess(file,data) {
	var index = attachIndex - 1;
	var jsonData=eval("("+data+")");//转换为json对象 
	var attachUrl=jsonData.attachUrl;
	var attachName=jsonData.attachName;
	$("#attachmentPaths"+index).val(attachUrl);
	$("#attachmentNames"+index).val(attachName);
}
function uploadPicsSuccess(file,imgUrl) {
	var index = picIndex - 1;
	$("#preImg"+index).attr("src",""+imgUrl);
	var imgSrc = parent.document.getElementById("preImg"+index);
	if(!$(imgSrc).attr("noResize")) {
		$(imgSrc).css("width","auto");
		$(imgSrc).css("height","auto");
	}
	$("#uploadImgPath"+index).val(imgUrl);
}
function yz(){
var other = document.getElementById("otherCarType").value;
var carTypeId=document.getElementById("carTypeId").value;
if(carTypeId==0){
if(other==null||other==""){
alert("其它车型不能为空,请输入!");
return false;
}
}
$("#jvForm").validate();
}
</script>
</head>
<body >
<div class="box-positon">
	<div class="rpos"><@s.m "global.position"/>: <@s.m "usedCar.function"/> - <@s.m "global.edit"/></div>
	<form class="ropt">
		<input type="button" value="<@s.m "global.backToList"/>" onclick="history.back();" class="return-button"/>
	</form>
	<div class="clear"></div>
</div>
<div class="body-box">
<#include "/common/image_upload.html"/>
<#include "attachment_upload.html"/>
<#assign usernameExist><@s.m "error.usernameExist"/></#assign>
<@p.form id="jvForm" action="o_update.do" labelWidth="12" onsubmit="return yz()">

<@p.text width="50" colspan="1" label="车量名称" name="title" value=usedCar.title class="required" required="true" maxlength="30"/>
<@p.select colspan="1" label="shopInfo.shopName" name="shopId"  list=listShop listKey="id" listValue="shopName" class="required" required="true"/><@p.tr/>

<@p.text width="50" colspan="1" label="行驶里程" name="mileage" value=usedCar.mileage class="required digits" required="true"/>
<@p.select colspan="1" label="品牌" id="carBrandId" name="carBrandId" value=usedCar.carBrand.id list=listCarBrand listKey="id" listValue="brandName" class="required" required="true"/><@p.tr/>

<@p.text width="50" colspan="1" label="价格(元)" name="price" value=usedCar.price class="required number" required="true" maxlength="10"/>
<@p.select colspan="1" label="车系" id="carSeriesId" name="carSeriesId" value=usedCar.carSeries.id list=listCarSeries listKey="id" listValue="shortName" class="required" required="true"/><@p.tr/>

<@p.textarea label="地址"  name="address" value=usedCar.address cols="30" rows="2" maxlength="500" colspan="1" class="required" required="true" width="50"/>
<@p.select colspan="1" label="新车车型" id="carTypeId" name="carTypeId" value=usedCar.carType.id list=listCarType listKey="id" listValue="typeName" class="required" required="true"/><@p.tr/>

<@p.text width="50" colspan="2" label="其它车系" id="otherCarType" name="otherCarType" value=usedCar.otherCarType help="如果新车车型中没有符合的二手车车型，请输入其它车系名称,且为必填项"/><@p.tr/>

<@p.radio colspan="1"  width="50" label="是否包过户" name="transOwner" value=usedCar.transOwner list={"1":"是","0","否"} class="required" required="true"/>
<@p.text width="50" colspan="1" label="新车总价(元)" name="ori_price"  value=usedCar.ori_price class="required number" required="true" maxlength="10"/><@p.tr/>

<@p.text width="50" colspan="1" label="变速箱" name="gearbox" value=usedCar.gearbox class="required" required="true" maxlength="30"/>
<@p.text width="50" colspan="1" label="排量" name="output" value=usedCar.output class="required" required="true" maxlength="30"/><@p.tr/>

<@p.text width="50" colspan="1" label="注册日期" name="registDate" value=usedCar.registDate class="Wdate" required="true" maxlength="30" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
<@p.text width="50" colspan="1" label="保险到期" name="insuranceExp" value=usedCar.insuranceExp class="Wdate" required="true" maxlength="30" onclick="WdatePicker({dateFmt:'yyyy-MM'})"/><@p.tr/>

<@p.text width="50" colspan="1" label="年检到期" name="motExp" value=usedCar.motExp class="Wdate" required="true" maxlength="30" onclick="WdatePicker({dateFmt:'yyyy-MM'})"/>
<@p.text width="50" colspan="1" label="车辆来源" name="carSource" value=usedCar.carSource  maxlength="30"/><@p.tr/>

<@p.text width="50" colspan="1" label="保养情况" name="maintain" value=usedCar.maintain class="required" required="true" maxlength="30"/>
<@p.text width="50" colspan="1" label="车辆类型" name="opertional" value=usedCar.opertional maxlength="30"/><@p.tr/>

<@p.textarea label="卖家描述"  name="sellerDesc" value=usedCar.sellerDesc cols="30" rows="2" maxlength="500" colspan="2" class="required" required="true" width="50"/><@p.tr/>
<@p.text width="50" colspan="1" label="联系人" name="linkPerson" value=usedCar.linkPerson class="required" required="true" maxlength="30"/>
<@p.text width="50" colspan="1" label="联系人电话" name="linkMobile" value=usedCar.linkMobile class="required" required="true" maxlength="30"/><@p.tr/>
<!-- 上传图片 -->
<@p.td label="图片" colspan="1" width="50" noHeight="true">
<@p.text id="uploadImgPath1" name="imgUrl" value=usedCar.imgUrl style="width:220px" class="required"  required="true"/>
<!--  <input type="button" value="<@s.m "imageupload.preview"/>" onclick="previewImg(1);" class="preview-button"/> --><br/>
<span id="ufc1" style="position:relative">
<input type='text' id='uploadFileText1' size="14"/>  
<input class="browse" type='button' value='<@s.m "global.browse"/>'/>
<input onchange="$('#uploadFileText1').val(this.value)" size="14" type="file" id="uploadFile1" class="file-button"/>
</span>
<label><input type="checkbox" onclick="$('#mark1').val(this.checked);"/><@s.m "imageupload.mark"/></label>
<input type="hidden" id="mark1" value="false"/> <input type="button" value="<@s.m "imageupload.upload"/>" onclick="upload(1);" class="upload-button"/><br/>
<@s.m "global.width"/>: <input type="text" id="zoomWidth1" value="100" size="5"/>
<@s.m "global.height"/>: <input type="text" id="zoomHeight1" value="70" size="5"/> 
<input type="button" value="<@s.m "imageupload.cut"/>" onclick="imgCut(1);" class="cut-button"/> 
</@p.td>
<@p.td colspan="1" width="50">
<img id="preImg1" alt="<@s.m "imageupload.preview"/>" style="width:100px;height:70px;background-color:#CCCCCC;border:1px solid #333"/>
</@p.td><@p.tr/>
<!-- 图片end -->


<!-- 批量上传 开始 -->
<@p.td label="批量上传" colspan="2" noHeight="true">
<div>
<span id="spanButtonPlaceHolder"></span>
<span style="display: none;"><input class="cancel" id="btnCancel" type="button" value="<@s.m "global.cancel"/>" onclick="swfu.cancelQueue();" disabled="disabled" /></span>
<div id="fsUploadProgress" style="display: none;"></div>
</div>
<#list usedCar.carImgs as p>
<table id="picTable${p_index+3}" border="0" style="float:left;">
<tr>
	<td>
		<div><input type="text" id="uploadImgPath${p_index+3}" name="imgUrls" value="${p.imgUrl}" style="width:170px"/> <a href="javascript:void(0);" onclick="$('#picTable${p_index+3}').remove();" class="pn-opt"><@s.m "content.picturesDel"/></a></div>
		<div>
		<span id="ufc${p_index+3}" style="position:relative">
		<input type='text' id='uploadFileText${p_index+3}' size="10"/>  
		<input class="browse" type='button' value='<@s.m "global.browse"/>'/>
		<input onchange="$('#uploadFileText${p_index+3}').val(this.value)" size="10" type="file" id="uploadFile${p_index+3}" class="file-button"/>
		</span> 
		<input type="button" value="<@s.m "content.fileUpload"/>" onclick="upload(${p_index+3});" class="upload-button"/>
		</div>图片名：
		<div><textarea style="width:200px;height:30px;"  name="imgNames" maxlength="255">${p.imgName!}</textarea></div>
	</td>
	<td><img id="preImg${p_index+3}" src="${p.imgUrl}" alt="<@s.m "imageupload.preview"/>" noResize="true" style="width:110px;height:110px;background-color:#ccc;border:1px solid #333"/></td>
</tr>
</table>
<input type="hidden" name="oldpicPaths" value="${p.imgUrl!}"/>
</#list>
<div id="picBefore" style="clear:both"></div>
<textarea id="picTable" style="display:none;">
<table id="picTable{0}" border="0" style="float:left;">
<tr>
	<td>
		<div><input type="text" id="uploadImgPath{0}" name="imgUrls" style="width:160px"/> <a href="javascript:void(0);" onclick="$('#picTable{0}').remove();" class="pn-opt"><@s.m "content.picturesDel"/></a></div>
		<div>
		<span id="ufc{0}" style="position:relative">
		<input type='text' id='uploadFileText{0}' size="10"/>  
		<input class="browse" type='button' value='<@s.m "global.browse"/>'/>
		<input onchange="$('#uploadFileText{0}').val(this.value)" size="10" type="file" id="uploadFile{0}" class="file-button"/>
		</span> 
		<input type="button" value="<@s.m "content.fileUpload"/>" onclick="upload({0});" class="upload-button"/>
		</div>
		<div>&lt;textarea style="width:200px;height:60px;" name="imgNames" maxlength="255"&gt;&lt;/textarea&gt;</div>
	</td>
	<td><img id="preImg{0}" alt="<@s.m "imageupload.preview"/>" noResize="true" style="width:110px;height:110px;background-color:#ccc;border:1px solid #333"/></td>
</tr>
</table>
</textarea>
<script type="text/javascript">
var picIndex = ${usedCar.carImgs?size} + 3;
var picTpl = $.format($("#picTable").val());
function addPicLine() {
	$('#picBefore').before(picTpl(picIndex++));
}
</script>
</@p.td>
<!-- 批量上传结束 -->
<@p.tr/>
<@p.hidden name="id" value=usedCar.id/>
<@p.td colspan="2"><@p.submit code="global.submit"/> &nbsp; <@p.reset code="global.reset"/></@p.td>

</@p.form>
</div>
</body>
</html>